package org.monkey.config.client.response;

import java.io.Serializable;

public class JsonResponse<T> implements Serializable {

  private String message;

  private boolean success;

  private String code;

  private T result;

  public JsonResponse() {}

  public JsonResponse(String message, boolean success, T result) {
    this.success = success;
    this.message = message;
    this.result = result;
  }

  public JsonResponse(String message, boolean success, T result, String code) {
    this.success = success;
    this.message = message;
    this.result = result;
    this.code = code;
  }

  public static <T> JsonResponse<T> success(String messages, T result) {
    return new JsonResponse<T>(messages, true, result);
  }

  public static <T> JsonResponse<T> fail(String messages, T result) {
    return new JsonResponse<T>(messages, false, result);
  }

  public T getResult() {
    return result;
  }

  public void setResult(T result) {
    this.result = result;
  }

  public String getMessage() {
    return message;
  }

  public void setMessage(String message) {
    this.message = message;
  }

  public boolean isSuccess() {
    return success;
  }

  public void setSuccess(boolean success) {
    this.success = success;
  }

  public String getCode() {
    return code;
  }

  public void setCode(String code) {
    this.code = code;
  }
}
